package com.ych.sys.entity;

import lombok.Data;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 * @BelongsProject: ape-frame
 * @BelongsPackage: com.ych.bean
 * @Author: ych
 * @CreateTime: 2024-11-19  12:05
 * @Description: TODO
 * @Version: 1.0
 */

@Data
public class PageResult<T> implements Serializable {
    /**
     * 总记录数
     */
    private Long total;

    /**
     * 每页记录数
     */
    private Long pageSize;

    /**
     * 当前页
     */
    private Long pageNo;

    /**
     * 总页数
     */
    private Long totalPages;

    /**
     * 数据集合
     */
    private List<T> records = Collections.emptyList();

    public void loadData(IPage<T> pageData) {
        this.setTotal(pageData.getTotal());
        this.setPageSize(pageData.getSize());
        this.setPageNo(pageData.getCurrent());
        this.setTotalPages(pageData.getPages());
        this.setRecords(pageData.getRecords());
    }
}
